import java.lang.reflect.Field;
//反射获取private 变量
public class test_reflect {
    private int num = 12;

    public static void main(String[] args) {
        test_reflect obj = new test_reflect();
        Class<? extends test_reflect> objClass = obj.getClass();
        try {

            Field num = objClass.getDeclaredField("num");
            //num.setAccessible(true);
            System.out.println(num.get(obj));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
